home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 February
/
EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso
/
earcd
/
comm2
/
kms20src.lha
/
KMSC
/
kms.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-09-16
|
7KB
|
307 lines
/**********************************
* KMS *
**********************************/
/*************************************************************************
*
* Copyright (C) 1995 Thomas Schwarz
* <kmshq@ruatha.muc.de>
* <Schwarz.Thomas@fhm.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*************************************************************************/
#include <KMS/KMS.h>
#include <KMS/KMS_devlib.h>
Prototype UWORD Break(VOID);
Prototype VOID wbmain(struct WBStartup *);
Prototype VOID main(UWORD, STRPTR *);
Prototype VOID HandleCall(VOID);
Prototype VOID WaitForCall(VOID);
extern VOID KPrintF(APTR, ...);
/*****************************
* Externe Globale Variablen *
*****************************/
extern struct KMSBase *KMSBase;
extern struct LocalConfig *KMS_LC;
extern UMSAccount MyUMSAccount;
extern UBYTE Plop;
extern struct UserNode DummyUser;
/*********************
* Globale Variablen *
*********************/
struct WBStartup *WBStart = NULL;
UBYTE ShutDown = 0;
BOOL Immediate = FALSE;
BOOL PreLogin = FALSE;
BOOL AutoShutDown = FALSE;
TEXT PreUser[LEN_USERNAME+1];
/******************************************
* Break-Handler *
******************************************
* I: --- *
* O: 0 *
******************************************/
/// "Break"
UWORD Break(VOID)
{
return 0;
}
///
/******************************************
* Hauptprogramm (Workbench-Einsprung) *
******************************************
* I: Argumente *
* O: --- *
******************************************/
/// "wbmain"
VOID wbmain(struct WBStartup *wbs)
{
WBStart = wbs;
main(0, NULL);
}
///
/******************************************
* Hauptprogramm *
******************************************
* I: Argumente *
* O: --- *
******************************************/
/// "main"
VOID main(UWORD argc, STRPTR *argv)
{
onbreak(Break);
if(OpenLib())
Sense(20);
if(OpenTimer())
Sense(20);
if(Identify())
Sense(20);
/* Dummy-User initialisieren */
InitUser(&DummyUser.UserData);
KMS_LC->Session.CurrentUser = &DummyUser;
if(WBStart && ParseToolTypes(WBStart))
Sense(20);
else if(!WBStart && ParseArgs())
Sense(20);
if(OpenDisplay())
Sense(20);
FlushInput();
KMS_LC->Session.Echo = FALSE; /* Echo aus */
SysMsg(KMS_OPEN_CLIENT);
while(!ShutDown)
{
WaitForCall();
if(!ShutDown)
{
Plop = 0;
KMS_LC->Session.HistPoint = KMS_LC->HistoryList.mlh_Head;
KMS_LC->Session.LoginTime = time(NULL); /* Startzeit festhalten */
KMS_LC->Session.MaxConnectTime = KMSBase->MaxConnectTime; /* Maximal-Verbindungszeit */
KMS_LC->Session.Warnings = 0; /* Inputtimeout-Warnungen = 0 */
KMS_LC->Session.Echo = TRUE; /* Echo ein */
KMS_LC->Session.CommMode = 0; /* Port-Msgs erlaubt */
KMS_LC->Session.Refresh = FALSE;
*KMS_LC->Session.Password = '\0';
*KMS_LC->Session.CurrCmd = '\0';
MsgPrint(NULL, 0);
ReadMsg(0, RF_RESET);
/* Anruf bearbeiten */
HandleCall();
}
Immediate = FALSE;
PreLogin = FALSE;
*PreUser = '\0';
if(AutoShutDown)
ShutDown = SHUTDOWN_IMMEDIATE;
}
CursorOn();
LogEntry(NULL);
Sense(0);
}
///
/*******************
* Zentral-Routine *
*******************
* I: --- *
* O: --- *
*******************/
/// "HandleCall"
VOID HandleCall(VOID)
{
if(KMSLogin())
{
HandleSession();
KMSLogout();
}
if(KMS_LC->Device & DEV_SERIAL)
Hangup();
}
///
/*****************************
* Auf nächsten Anruf warten *
*****************************
* I: --- *
* O: --- *
*****************************/
/// "WaitForCall"
extern struct MsgPort *WritePort;
VOID WaitForCall(VOID)
{
BOOL res;
BOOL exit = FALSE;
CursorOn();
FlushInput();
if(Immediate)
{
/* Sofort-Login */
SetMode(KMS_LC->InHandle, 2); /* Carrier-Check EIN */
exit = TRUE;
}
else
{
/* Modemreset */
SetMode(KMS_LC->InHandle, 4); /* Carrier-Check AUS */
if(KMS_LC->Device & DEV_SERIAL)
ResetModem();
}
/* Auf Anruf bzw. RETURN von Konsole warten */
while(!exit)
{
FlushInput();
Plop = 0;
KMS_LC->Session.LineSpeed = 0;
if(KMS_LC->Device & DEV_SERIAL)
{
/* Eine Minute auf "RING" warten */
res = ModemWait(60, KMSBase->ModemRingString);
}
else
{
/* Eine Minute auf [Return] von Tastatur warten */
res = ModemWait(60, "\r");
}
/* Falls ShutDown-Kommando kam, Schluß machen */
if(ShutDown)
{
CursorOff();
return;
}
/* Falls nicht gerade Logins gesperrt sind, Input auswerten */
if(res && !KMS_LC->Locked)
{
/* Modem oder Tastatur? */
if(KMS_LC->Device & DEV_SERIAL)
{
/* Telefoooooon! Wenn CONNECT, dann raus */
if (!MyUMSAccount && AnswerPhone())
{
SetMode(KMS_LC->InHandle, 2); /* Carrier-Check EIN */
exit = TRUE;
}
else
Hangup();
}
else if(KMS_LC->Device & DEV_CONSOLE)
{
/* Lokale Sitzung */
if(!MyUMSAccount) /* (Wenn kein REXX-Login!) */
exit = TRUE;
}
}
}
FlushInput();
SysMsg(KMS_START_SESSION);
CursorOff();
}
///